import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

///////////////////////////////////////////////////////////////////////////
// 路由配置
// 参考教程：https://blog.csdn.net/weixin_38404899/article/details/90229805
//
///////////////////////////////////////////////////////////////////////////
const constantRouter = new Router({
  mode: "hash",
  routes: [
    {
      path: "/",
      name: "首页",
      component: () => import("@/views/layout"),
      redirect: "/drive",
      children: [
        {
          path: "/drive",
          name: "驱动管理",
          icon: "el-icon-data-line",
          component: () => import("@/views/drive/index"),
        },
        {
          path: "/monitor",
          name: "监控管理",
          icon: "el-icon-monitor",
          component: () => import("@/views/monitor/index"),
        },
        {
          path: "/plugIn",
          name: "插件管理",
          icon: "el-icon-share",
          component: () => import("@/views/plugIn/index"),
        },
        {
          path: "/setting",
          name: "配置管理",
          icon: "el-icon-s-tools",
          redirect: "/setting/system",
          component: () => import("@/views/setting/index"),
          children: [
            {
              path: "/setting/system",
              name: "系统参数",
              component: () => import("@/views/setting/system"),
            },
            {
              path: "/setting/user",
              name: "用户管理",
              component: () => import("@/views/setting/user"),
            },
            {
              path: "/setting/allocation",
              name: "配置管理",
              component: () => import("@/views/setting/allocation"),
            },
          ],
        },
        {
          path: "/template",
          name: "页面模板",
          icon: "el-icon-menu",
          redirect: "/template/list",
          component: () => import("@/views/template/index"),
          children: [
            {
              path: "/template/list",
              name: "列表模板",
              component: () => import("@/views/template/list"),
            },
            {
              path: "/template/sql",
              name: "sql转换",
              component: () => import("@/views/template/sql"),
            },
          ],
        },
        {
          path: "/office",
          name: "在线预览文档",
          icon: "el-icon-menu",
          component: () => import("@/views/office/index"),
        },
      ],
    },

    {
      path: "/login",
      name: "登录",
      component: () => import("@/views/login"),
    },
  ],
});

// 动态路由
// constantRouter.addRoute("首页", {
// 	path: '/office',
// 	name: '在线预览文档',
// 	icon: "el-icon-menu",
// 	component: () => import('@/views/office/index')
// });

/** 路由守卫 **/
// constantRouter.beforeEach((to, from, next)=>{
// 	let username = sessionStorage.getItem("username");
// 	if(!username){
// 	    next("/login")
// 	}else{
// 	    next();
// 	}
// 	next();
// })

export default constantRouter;
